import numpy as np


def linear(x, n: int):
    assert (-1 <= x.all() <= 1)
    j = np.floor(n * (x + 1) / 2)
    xj = 2 * j / n - 1
    return f(xj) + (f(xj + 2 / n) - f(xj)) * (x - xj) * n / 2


def f(x: float):
    return 1 / (1 + 25 * x ** 2)
